package com.xyz.tasks;

import com.free.ext.logger.FreeLogger;
import com.free.ext.logger.FreeLoggerFactory;
import com.free.ext.spring.context.AppContext;
import com.free.messager.IMessager;
import com.free.messager.MessagerManager;
import com.xyz.tasks.schedules.YldtTaskCenter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;

@Component
public class XyzTaskRunner implements ApplicationRunner {

    private static FreeLogger LOG = FreeLoggerFactory.getLogger(XyzTaskRunner.class);

    @Autowired
    private YldtTaskCenter yldtTaskCenter;

    @Override
    public void run(ApplicationArguments applicationArguments) throws Exception {
        // message 处理
        IMessager mesager = AppContext.getBean(IMessager.class);
        MessagerManager.current().setMessager(mesager);

        loadTasks();
    }

    // 导入任务
    private void loadTasks(){
        yldtTaskCenter.loadTasks();
    }

}
